<template>
  <el-dialog
    :visible.sync="showDialog"
    :title="$t('盘点记录')"
    width="900px"
    destroy-on-close
    :close-on-click-modal="false">
    <div class="app-container">
      <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
        <el-form-item :label="$t('库位号')">
          <el-input clearable v-model="queryParams.spNo" />
        </el-form-item>

        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="getList"
          >
            {{ $t("搜索") }}
          </el-button>
        </el-form-item>
      </el-form> -->

      <el-table :height="calTableHeight() - 50" v-loading="loading" :data="tableData" row-key="menuId">
        <!-- 库位号 -->
        <el-table-column show-overflow-tooltip :label="$t('库位号')" align="center" prop="positionNo" />
        <!-- 盘点类型 -->
        <el-table-column show-overflow-tooltip :label="$t('盘点类型')" align="center" prop="type">
          <template slot-scope="{ row }">
            <span v-if="row.type == 1">{{ $t('扫码盘点') }}</span>
            <span v-if="row.type == 2">{{ $t('手动+扫码盘点') }}</span>
          </template>
        </el-table-column>
        <!-- 快照数量 -->
        <el-table-column show-overflow-tooltip prop="stockSnap" :label="$t('快照数量')" align="center" />
        <!-- 确认数量 -->
        <el-table-column show-overflow-tooltip prop="confirmNum" :label="$t('确认数量')" align="center" />
        <!-- 差异数量 -->
        <el-table-column show-overflow-tooltip prop="differenceNum" :label="$t('差异数量')" align="center" />
        <!-- 日期 -->
        <el-table-column
          show-overflow-tooltip
          prop="updateTime"
          :label="$t('日期')"
          width="150"
          align="center" />
      </el-table>
      <pagination
        v-show="pageTotal > 0"
        :total="pageTotal"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
  </el-dialog>
</template>

<script>
import { skuCheckRecordList } from '@/api/distribution/sku/Inventory'

export default {
  components: {},
  data() {
    return {
      title: '',
      tableData: [],
      showDialog: false,
      /**数据总条数 */
      pageTotal: 0,
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        skuId: '',
      },
    }
  },
  created() {},

  methods: {
    handleType(type) {
      // 记录类型 1 扫码入库，2 根据采购单入库，3退货入库，4.盘点入库，11订单出库，12过期销毁，13损坏出库，14补发出库，15盘点出库
      switch (+type) {
        case 1:
          return '扫码入库'
        case 2:
          return '根据采购单入库'
        case 3:
          return '退货入库'
        case 4:
          return '盘点入库'
        case 11:
          return '订单出库'
        case 12:
          return '过期销毁'
        case 13:
          return '损坏出库'
        case 14:
          return '补发出库'
        case 15:
          return '盘点出库'
        default:
          break
      }
    },
    handleOpen({ title, skuId }) {
      this.title = title
      this.queryParams.skuId = skuId
      this.getList()
      this.showDialog = true
    },

    /** 查询菜单列表 */
    getList() {
      this.loading = true
      skuCheckRecordList(this.queryParams).then((res) => {
        this.tableData = res.rows
        this.pageTotal = res.total
        this.loading = false
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.getList()
    },
  },
}
</script>
<style lang="scss" scoped></style>
